package com.example.shushiyunsst.fragment.main.home.child.new_sale.chlid.bean;

import android.text.TextUtils;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONField;

public class GoodsDetailLikeListBean {

    /**
     * goodsPics : {"pics":[{"url":"http://162.247.99.201:81/shop/shop_top.jpg"},{"url":"http://162.247.99.201:81/shop/shop_top.jpg"},{"url":"http://162.247.99.201:81/shop/shop_top.jpg"}]}
     * gid : 6
     * goodsColor : {"color":[{"name":"蓝色"},{"name":"黑红色"}]}
     * goodsSize : {"size":[{"name":"L"},{"name":"XL"}]}
     * updateTime : 2020-09-18 16:11:03
     * goodsOldPrice : 100
     * goodsContent : {"pics":[{"url":"http://162.247.99.201:81/shop/shop_top.jpg"},{"url":"http://162.247.99.201:81/shop/shop_top.jpg"},{"url":"http://162.247.99.201:81/shop/shop_top.jpg"}]}
     * goodsStock : 97
     * goodsSales : 3
     * catId : 1,7,11,12,13
     * goodsStatus : 1
     * createTime : 2020-09-18 16:11:03
     * goodsPrice : 73
     * goodsName : 俗世堂海参牡蛎复合肽
     * goodsFare : 0
     */

    @JSONField(name = "goodsPics")
    private String goodsPics;

    @JSONField(name = "gid")
    private int gid;

    @JSONField(name = "goodsColor")
    private String goodsColor;

    @JSONField(name = "goodsSize")
    private String goodsSize;

    @JSONField(name = "updateTime")
    private String updateTime;

    @JSONField(name = "goodsOldPrice")
    private int goodsOldPrice;

    @JSONField(name = "goodsContent")
    private String goodsContent;

    @JSONField(name = "goodsStock")
    private int goodsStock;

    @JSONField(name = "goodsSales")
    private int goodsSales;

    @JSONField(name = "catId")
    private String catId;

    @JSONField(name = "goodsStatus")
    private int goodsStatus;

    @JSONField(name = "createTime")
    private String createTime;

    @JSONField(name = "goodsPrice")
    private int goodsPrice;

    @JSONField(name = "goodsName")
    private String goodsName;

    @JSONField(name = "goodsFare")
    private int goodsFare;

    @JSONField(name = "givenCml")
    private double givenCml;

    public double getGivenCml() {
        return givenCml;
    }

    public void setGivenCml(double givenCml) {
        this.givenCml = givenCml;
    }

    private String defaultImg = "";

    public String getDefaultImg() {
        if (TextUtils.isEmpty(defaultImg)) {
            defaultImg = parseGoodsPics();
        }
        return defaultImg;
    }

    public String parseGoodsPics() {

        String picStr = "";

        JSONObject mPics = JSON.parseObject(goodsPics);

        Object pics = mPics.get("pics");

        if (pics == null) return picStr;

        JSONArray array = JSON.parseArray(pics.toString());

        if (array.size() > 0) {
            Object o = array.get(0);
            if (o instanceof JSONObject) {
                picStr = ((JSONObject) o).getString("url");
            }
        }
        return picStr;
    }


    public String getGoodsPics() {
        return goodsPics;
    }

    public void setGoodsPics(String goodsPics) {
        this.goodsPics = goodsPics;
    }

    public int getGid() {
        return gid;
    }

    public void setGid(int gid) {
        this.gid = gid;
    }

    public String getGoodsColor() {
        return goodsColor;
    }

    public void setGoodsColor(String goodsColor) {
        this.goodsColor = goodsColor;
    }

    public String getGoodsSize() {
        return goodsSize;
    }

    public void setGoodsSize(String goodsSize) {
        this.goodsSize = goodsSize;
    }

    public String getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(String updateTime) {
        this.updateTime = updateTime;
    }

    public int getGoodsOldPrice() {
        return goodsOldPrice;
    }

    public void setGoodsOldPrice(int goodsOldPrice) {
        this.goodsOldPrice = goodsOldPrice;
    }

    public String getGoodsContent() {
        return goodsContent;
    }

    public void setGoodsContent(String goodsContent) {
        this.goodsContent = goodsContent;
    }

    public int getGoodsStock() {
        return goodsStock;
    }

    public void setGoodsStock(int goodsStock) {
        this.goodsStock = goodsStock;
    }

    public int getGoodsSales() {
        return goodsSales;
    }

    public void setGoodsSales(int goodsSales) {
        this.goodsSales = goodsSales;
    }

    public String getCatId() {
        return catId;
    }

    public void setCatId(String catId) {
        this.catId = catId;
    }

    public int getGoodsStatus() {
        return goodsStatus;
    }

    public void setGoodsStatus(int goodsStatus) {
        this.goodsStatus = goodsStatus;
    }

    public String getCreateTime() {
        return createTime;
    }

    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }

    public int getGoodsPrice() {
        return goodsPrice;
    }

    public void setGoodsPrice(int goodsPrice) {
        this.goodsPrice = goodsPrice;
    }

    public String getGoodsName() {
        return goodsName;
    }

    public void setGoodsName(String goodsName) {
        this.goodsName = goodsName;
    }

    public int getGoodsFare() {
        return goodsFare;
    }

    public void setGoodsFare(int goodsFare) {
        this.goodsFare = goodsFare;
    }


}
